package view.relatorios;

import java.util.ArrayList;
import java.util.List;

import model.entidades.Consulta;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.view.JasperViewer;

public class Relatorios {

	private static String CAMINHO_JASPER_RECEITA = "./jasper/receituario.jasper";
	
	private static String CAMINHO_JASPER_HISTORICO = "./jasper/historico.jasper";


	public static void gerarReceita(Consulta consulta) {
		
		List<Consulta> receita = new ArrayList<Consulta>();
		receita.add(consulta);

		JRDataSource jrds = new JRBeanCollectionDataSource(receita);

		try {
			JasperPrint print = JasperFillManager.fillReport(CAMINHO_JASPER_RECEITA, null, jrds);
			JasperViewer.viewReport(print, false);
		} catch (JRException e) {
			e.printStackTrace();
		}

	}
	
	public static void gerarHistoricoAtendimentos(List<Consulta> consultas) {

		JRDataSource jrds = new JRBeanCollectionDataSource(consultas);

		try {
			JasperPrint print = JasperFillManager.fillReport(CAMINHO_JASPER_HISTORICO, null, jrds);
			JasperViewer.viewReport(print, false);
		} catch (JRException e) {
			e.printStackTrace();
		}

	}

}
